package com.valley.boot;

import java.lang.instrument.Instrumentation;

/**
 * Hello world!
 *
 */
public class App 
{
    public static  void premain(String arguments, Instrumentation instrumentation) {
        System.out.println("agent-init");


        try {
            Class<?>[] allLoadedClasses = instrumentation.getAllLoadedClasses();
            for (Class<?> allLoadedClass : allLoadedClasses) {
                if (allLoadedClass.getName().equals(TransformCode.className)){
                    instrumentation.retransformClasses(allLoadedClass);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        instrumentation.addTransformer(new TransformCode(),true);

    }

}
